package com.oauth.facebook.client.ui;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.DeckPanel;
import com.google.gwt.user.client.ui.Widget;
import com.oauth.components.client.rpc.OAuthAsnyCallBack;
import com.oauth.facebook.client.beans.FacebookModel;
import com.oauth.facebook.client.rpc.FacebookRemoteServiceAsync;

public class MainPanel extends Composite {

	private static MainPanelUiBinder uiBinder = GWT.create(MainPanelUiBinder.class);

	interface MainPanelUiBinder extends UiBinder<Widget, MainPanel> {
	}

	@UiField
	DeckPanel deckPanel;

	@UiField
	HomePanel homePanel;

	public MainPanel() {
		initWidget(uiBinder.createAndBindUi(this));
	}

	public void initMainPanel() {
		deckPanel.showWidget(0);
		FacebookRemoteServiceAsync.INSTANCE.getHomeData(new OAuthAsnyCallBack<FacebookModel>() {

			public void onSuccess(FacebookModel result) {
				deckPanel.showWidget(1);
				homePanel.setData(result);
			}

		});
	}

}